home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form frmCD
- Caption = "Common Dialogs Example"
- ClientHeight = 3870
- ClientLeft = 1095
- ClientTop = 1485
- ClientWidth = 7365
- Height = 4275
- Left = 1035
- LinkTopic = "Form1"
- ScaleHeight = 3870
- ScaleWidth = 7365
- Top = 1140
- Width = 7485
- Begin CommonDialog CMDialog1
- Left = 6840
- Top = 3360
- End
- Begin CommandButton btnCD
- Caption = "Close"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 495
- Index = 5
- Left = 5685
- TabIndex = 6
- Top = 2835
- Width = 1215
- End
- Begin CommandButton btnCD
- Caption = "Print"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 495
- Index = 4
- Left = 5685
- TabIndex = 5
- Top = 2340
- Width = 1215
- End
- Begin CommandButton btnCD
- Caption = "Font"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 495
- Index = 3
- Left = 5685
- TabIndex = 4
- Top = 1845
- Width = 1215
- End
- Begin CommandButton btnCD
- Caption = "Color"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 495
- Index = 2
- Left = 5685
- TabIndex = 3
- Top = 1350
- Width = 1215
- End
- Begin CommandButton btnCD
- Caption = "Save As"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 495
- Index = 1
- Left = 5685
- TabIndex = 2
- Top = 855
- Width = 1215
- End
- Begin CommandButton btnCD
- Caption = "Open"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 495
- Index = 0
- Left = 5685
- TabIndex = 1
- Top = 360
- Width = 1215
- End
- Begin TextBox txtCD
- Height = 3510
- Left = 75
- MultiLine = -1 'True
- TabIndex = 0
- Top = 165
- Width = 5130
- End
- Sub btnCD_Click (Index As Integer)
- Dim BeginPage, EndPage, NumPage
- Select Case Index
- Case 0 'User chose Open
- CMDialog1.Filename = ""
- CMDialog1.Filter = "Text Files (*.TXT)|*.TXT|Batch Files (*.BAT)|*.BAT|All Files (*.*)|*.*"
- CMDialog1.FilterIndex = 1
- CMDialog1.Action = 1
- Filename = CMDialog1.Filename
- OpenFile (Filename)
- txtCD.SetFocus
- Case 1 'User chose Save As
- CMDialog1.Filename = ""
- CMDialog1.Filter = "Text Files (*.TXT)|*.TXT|Batch Files (*.BAT)|*.BAT|All Files (*.*)|*.*"
- CMDialog1.FilterIndex = 1
- CMDialog1.Action = 2
- Filename = CMDialog1.Filename
- CloseFile (Filename)
- Case 2 'User chose Color
- CMDialog1.CancelError = True
- On Error GoTo ErrHandler
- CMDialog1.Flags = &H1&
- CMDialog1.Action = 3
- frmCD.BackColor = CMDialog1.Color
- Case 3 'User chose Font
- CMDialog1.CancelError = True
- On Error GoTo ErrHandler
- CMDialog1.Flags = &H1&
- CMDialog1.Action = 4
- txtCD.FontName = CMDialog1.FontName
- txtCD.FontSize = CMDialog1.FontSize
- txtCD.FontBold = CMDialog1.FontBold
- txtCD.FontItalic = CMDialog1.FontItalic
- txtCD.FontUnderLine = CMDialog1.FontUnderLine
- txtCD.FontStrikeThru = CMDialog1.FontStrikeThru
- txtCD.ForeColor = CMDialog1.Color
- Case 4 'User chose Print
- On Error Resume Next
- CMDialog1.CancelError = True
- CMDialog1.Flags = PD_ALLPAGES Or PD_DISABLEPRINTTOFILE Or PD_NOPAGENUMS Or PD_SHOWHELP
- CMDialog1.Min = 1
- CMDialog1.Max = 1
- CMDialog1.Action = 5
- If Err = 32755 Then Exit Sub
- Copies% = CMDialog1.Copies
- For I% = 1 To Copies%
- T$ = frmCD.txtCD.Text
- 'Get the formatted text(50 Characters wide).
- 'Uses the WordWrap function of the Procedures
- 'section of this form.
- Wrapped$ = WordWrap$(T$, 50)'<== Change this number to change the width of the printed text.
- Printer.Print Wrapped$
- Printer.NewPage
- Next I%
- Printer.EndDoc
- Case 5 'User chose Close
- txtCD.Text = ""
- Unload frmCD
- End Select
- ErrHandler:
- Exit Sub
- End Sub
- Function WordWrap$ (St$, length)
- 'This WordWrap function was written by Carl Franklin.
- ' This function converts raw text into CRLF delimited lines.
- length = length + 1
- St$ = Trim$(St$)
- Cr$ = Chr$(13)
- Crlf$ = Chr$(13) & Chr$(10)
- Do
- L = Len(NextLine$)
- S = InStr(St$, " ")
- C = InStr(St$, Cr$)
- If C Then
- If L + C <= length Then
- Text$ = Text$ & NextLine$ & Left$(St$, C)
- NextLine$ = ""
- St$ = Mid$(St$, C + 1)
- GoTo LoopHere
- End If
- End If
- If S Then
- If L + S <= length Then
- DoneOnce = True
- NextLine$ = NextLine$ & Left$(St$, S)
- St$ = Mid$(St$, S + 1)
- ElseIf S > length Then
- Text$ = Text$ & Crlf$ & Left$(St$, length)
- St$ = Mid$(St$, length + 1)
- Else
- Text$ = Text$ & NextLine$ & Crlf$
- NextLine$ = ""
- End If
- If L Then
- If L + Len(St4) > length Then
- Text$ = Text$ & NextLine$ & Crlf$ & St$ & Crlf$
- Else
- Text$ = Text$ & NextLine$ & St$ & Crlf$
- End If
- Else
- Text$ = Text$ & St$ & Crlf$
- End If
- Exit Do
- End If
- LoopHere:
- Loop
- WordWrap$ = Text$
- End Function
-